package com.song.pj.arithmetic.service;

import com.song.pj.common.exception.ServiceException;
import org.springframework.stereotype.Service;

@Service
public class ArithemticService {
    public int sum(int a ,int b){
        return a+b;
    }
//    @RequestMapping("/doSum")
    public int sum(Integer... nums) {
        int sums = 0;
        if (nums == null || nums.length == 0)
            //throw new RuntimeException("参数值不能为负数")
            throw new ServiceException("数组不能为空");

            for (int i = 0; i < nums.length; i++) {
                sums += nums[i];
            }

        return sums;
    }
}
